import os
# -*- coding:utf-8 -*-
import os
import sys
from loguru import logger

pythonPath = os.path.join(os.path.dirname(__file__), '..')
if pythonPath not in sys.path:
    sys.path.append(pythonPath)
logger.add('./logs/info.log', format="{time:YYYY-MM-DD HH:mm:ss.SSS}|{level}|{message}")


class Config:
    """
    配置文件
    """
    PYTHON_PORT = 6001
    API_INDEX = "/api/p/AI/"
    APP_SESSION_COOKIE_NAME = 'medical-AI-nlp'
    APP_SECRET_KEY = 'medical-AI-nlp'
    DATA_HOME = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
    """---bm25----"""
    BM25_MODEL = os.path.join(DATA_HOME, "BM25/BM25model")
    BM25_MODEL_WORDS = os.path.join(DATA_HOME, "BM25/BM25modelWORD")


CONFIG = Config()
# 读取环境变量,更新到Config后，以和容器一起使用
for k in os.environ:
    if k in Config.__dict__:
        print('use environ var:', k, os.environ.get(k))
        setattr(Config, k, os.environ.get(k))
CONFIG = Config()
for k in os.environ:
    if k in CONFIG.__dict__:
        print('use environ var:', k, os.environ.get(k))
        CONFIG.__dict__[k] = os.environ.get(k)
